/*
 * Copyright © 2015-2026 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dongxing.springbootrocketmqstarter.annotation;


import com.dongxing.springbootrocketmqstarter.core.ConsumeMode;
import com.dongxing.springbootrocketmqstarter.core.SelectorType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.springframework.stereotype.Component;

import java.lang.annotation.*;

/**
 * <pre>
 * 名称: RocketMQMessageListener
 * 描述: RocketMq 消息监听注解
 * </pre>
 * @author dongxing
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface RocketMQMessageListener {

    /** 心跳周期 */
    int HEARTBEAT_BROKER_INTERVAL = 1000 * 30;
    /** pollNameServer周期 */
    int POLL_NAME_SERVER_INTERVAL = 1000 * 30;
    /** 批量拉取消息数量 */
    int PULL_BATCH_SIZE = 32;

    /**
     * RocketMQ nameServer
     * 优先取该注解，没有则取{@link RocketMQProperties#nameServer}
     * @return string
     */
    String nameServer() default "";

    /**
     * 消费组
     * @return string
     */
    String consumerGroup();

    /**
     * Topic
     * @return string
     */
    String topic();

    /**
     * 消息表达式类型
     * 默认按照TAG
     * @return SelectorType
     */
    SelectorType selectorType() default SelectorType.TAG;

    /**
     * selectorExpress
     * @return String
     */
    String selectorExpress() default "*";

    /**
     * 默认同时消费, 消费 模式
     * @return ConsumeMode
     */
    ConsumeMode consumeMode() default ConsumeMode.CONCURRENTLY;

    /**
     * 默认集群消费，消息模式
     * @return MessageModel
     */
    MessageModel messageModel() default MessageModel.CLUSTERING;

    /**
     * 消费者最小线程
     * @return String
     */
    String consumeThreadMin() default "20";

    /**
     * 消费者最大线程
     * @return String
     */
    String consumeThreadMax() default "64";

    /**
     * 批量消费数量
     * @see MessageListenerConcurrently#consumeMessage
     * @return int
     */
    int consumeMessageBatchMaxSize() default 1;

    /**
     * 批量拉取消息数量, 默认：32
     * @return int
     */
    int pullBatchSize() default PULL_BATCH_SIZE;

    /**
     * pollNameServer周期, 默认：30000
     * @return int
     */
    int pollNameServerInterval() default POLL_NAME_SERVER_INTERVAL;

    /**
     * 心跳周期, 默认：30000
     * @return int
     */
    int heartbeatBrokerInterval() default HEARTBEAT_BROKER_INTERVAL;

    /**
     * 是否使用vip通道, 默认：ture
     * @return boolen
     */
    boolean vipChannelEnabled() default true;

}
